package com.usian.ai.common;

import com.usian.ai.common.enums.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 12 03 10 08
 **/

@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class Result {

    private Integer code;
    private String msg;
    private Object data;

    private Result(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }




    public static Result ok(Object data){
        return new Result(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg(), data);
    }

    public static Result ok(){
        return new Result(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg());
    }

    public static Result ok(ResultCodeEnum resultCodeEnum){
        return new Result(resultCodeEnum.getCode(),resultCodeEnum.getMsg());
    }

    public static Result ok(ResultCodeEnum resultCodeEnum,Object data){
        return new Result(resultCodeEnum.getCode(),resultCodeEnum.getMsg(),data);
    }



    public static Result fail(){
        return new Result(ResultCodeEnum.FAIL.getCode(),ResultCodeEnum.FAIL.getMsg());
    }

    public static Result fail(Object data){
        return new Result(ResultCodeEnum.FAIL.getCode(),ResultCodeEnum.FAIL.getMsg(), data);
    }
    public static Result fail(ResultCodeEnum resultCodeEnum){
        return new Result(resultCodeEnum.getCode(),resultCodeEnum.getMsg());
    }

    public static Result fail(ResultCodeEnum resultCodeEnum,Object data){
        return new Result(resultCodeEnum.getCode(),resultCodeEnum.getMsg(),data);
    }


}
